<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Returns an array of information describing this server</title>
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-base.css" />
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-medium.css" />

 </head>
 <body class="docs"><div class="navbar navbar-fixed-top">
  <div class="navbar-inner clearfix">
    <ul class="nav" style="width: 100%">
      <li style="float: left;"><a href="mongodb-driver-server.gethost.html">« MongoDB\Driver\Server::getHost</a></li>
      <li style="float: right;"><a href="mongodb-driver-server.getlatency.html">MongoDB\Driver\Server::getLatency »</a></li>
    </ul>
  </div>
</div>
<div id="breadcrumbs" class="clearfix">
  <ul class="breadcrumbs-container">
    <li><a href="index.html">PHP Manual</a></li>
    <li><a href="class.mongodb-driver-server.html">MongoDB\Driver\Server</a></li>
    <li>Returns an array of information describing this server</li>
  </ul>
</div>
<div id="layout">
  <div id="layout-content"><div id="mongodb-driver-server.getinfo" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">MongoDB\Driver\Server::getInfo</h1>
  <p class="verinfo">(mongodb &gt;=1.0.0)</p><p class="refpurpose"><span class="refname">MongoDB\Driver\Server::getInfo</span> &mdash; <span class="dc-title">Returns an array of information describing this server</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-mongodb-driver-server.getinfo-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="modifier">final</span> <span class="modifier">public</span> <span class="methodname"><strong>MongoDB\Driver\Server::getInfo</strong></span>(): <span class="type">array</span></div>

  <p class="para rdfs-comment">
   Returns an array of information describing the server. This array is derived
   from the most recent
   <a href="https://www.mongodb.com/docs/manual/reference/command/hello/" class="link external">&raquo;&nbsp;hello</a>
   command response obtained through
   <a href="https://github.com/mongodb/specifications/blob/master/source/server-discovery-and-monitoring/server-discovery-and-monitoring.rst" class="link external">&raquo;&nbsp;server monitoring</a>.
  </p>
  <blockquote class="note"><p><strong class="note">注意</strong>: 
   <p class="para">
    When the driver is connected to a load balancer, this method will return
    the backing server&#039;s
    <a href="https://www.mongodb.com/docs/manual/reference/command/hello/" class="link external">&raquo;&nbsp;hello</a>
    command response from the initial connection handshake. This is in contrast
    to other methods (e.g. <span class="function"><a href="mongodb-driver-server.gettype.html" class="function">MongoDB\Driver\Server::getType()</a></span>),
    which will return information about the load balancer itself.
   </p>
  </p></blockquote>
 </div>


 <div class="refsect1 parameters" id="refsect1-mongodb-driver-server.getinfo-parameters">
  <h3 class="title">参数</h3>
  <p class="para">此函数没有参数。</p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-mongodb-driver-server.getinfo-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   Returns an array of information describing this server.
  </p>
 </div>


 <div class="refsect1 errors" id="refsect1-mongodb-driver-server.getinfo-errors">
  <h3 class="title">错误／异常</h3>
  <ul class="simplelist">
   <li class="member">Throws <span class="classname"><a href="class.mongodb-driver-exception-invalidargumentexception.html" class="classname">MongoDB\Driver\Exception\InvalidArgumentException</a></span> on argument parsing errors.</li>
  </ul>
 </div>



 <div class="refsect1 examples" id="refsect1-mongodb-driver-server.getinfo-examples">
  <h3 class="title">范例</h3>
  <div class="example" id="example-1346">
   <p><strong>示例 #1 <span class="function"><strong>MongoDB\Driver\Server::getInfo()</strong></span> example</strong></p>
   <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /><br />$manager&nbsp;</span><span style="color: #007700">=&nbsp;new&nbsp;</span><span style="color: #0000BB">MongoDB</span><span style="color: #007700">\</span><span style="color: #0000BB">Driver</span><span style="color: #007700">\</span><span style="color: #0000BB">Manager</span><span style="color: #007700">(</span><span style="color: #DD0000">'mongodb://localhost:27017/'</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">$rp&nbsp;</span><span style="color: #007700">=&nbsp;new&nbsp;</span><span style="color: #0000BB">MongoDB</span><span style="color: #007700">\</span><span style="color: #0000BB">Driver</span><span style="color: #007700">\</span><span style="color: #0000BB">ReadPreference</span><span style="color: #007700">(</span><span style="color: #DD0000">'primary'</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$server&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">$manager</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">selectServer</span><span style="color: #007700">(</span><span style="color: #0000BB">$rp</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">$server</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">getInfo</span><span style="color: #007700">());<br /><br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
   </div>

   <div class="example-contents"><p>以上例程的输出类似于：</p></div>
   <div class="example-contents screen">
<div class="cdata"><pre>
array(23) {
  [&quot;helloOk&quot;]=&gt;
  bool(true)
  [&quot;topologyVersion&quot;]=&gt;
  array(2) {
    [&quot;processId&quot;]=&gt;
    object(MongoDB\BSON\ObjectId)#4 (1) {
      [&quot;oid&quot;]=&gt;
      string(24) &quot;617b6d696a3a89d2f77e6df0&quot;
    }
    [&quot;counter&quot;]=&gt;
    int(6)
  }
  [&quot;hosts&quot;]=&gt;
  array(1) {
    [0]=&gt;
    string(15) &quot;localhost:27017&quot;
  }
  [&quot;setName&quot;]=&gt;
  string(3) &quot;rs0&quot;
  [&quot;setVersion&quot;]=&gt;
  int(1)
  [&quot;ismaster&quot;]=&gt;
  bool(true)
  [&quot;secondary&quot;]=&gt;
  bool(false)
  [&quot;primary&quot;]=&gt;
  string(15) &quot;localhost:27017&quot;
  [&quot;me&quot;]=&gt;
  string(15) &quot;localhost:27017&quot;
  [&quot;electionId&quot;]=&gt;
  object(MongoDB\BSON\ObjectId)#5 (1) {
    [&quot;oid&quot;]=&gt;
    string(24) &quot;7fffffff0000000000000001&quot;
  }
  [&quot;lastWrite&quot;]=&gt;
  array(4) {
    [&quot;opTime&quot;]=&gt;
    array(2) {
      [&quot;ts&quot;]=&gt;
      object(MongoDB\BSON\Timestamp)#6 (2) {
        [&quot;increment&quot;]=&gt;
        string(1) &quot;1&quot;
        [&quot;timestamp&quot;]=&gt;
        string(10) &quot;1635478989&quot;
      }
      [&quot;t&quot;]=&gt;
      int(1)
    }
    [&quot;lastWriteDate&quot;]=&gt;
    object(MongoDB\BSON\UTCDateTime)#7 (1) {
      [&quot;milliseconds&quot;]=&gt;
      string(13) &quot;1635478989000&quot;
    }
    [&quot;majorityOpTime&quot;]=&gt;
    array(2) {
      [&quot;ts&quot;]=&gt;
      object(MongoDB\BSON\Timestamp)#8 (2) {
        [&quot;increment&quot;]=&gt;
        string(1) &quot;1&quot;
        [&quot;timestamp&quot;]=&gt;
        string(10) &quot;1635478989&quot;
      }
      [&quot;t&quot;]=&gt;
      int(1)
    }
    [&quot;majorityWriteDate&quot;]=&gt;
    object(MongoDB\BSON\UTCDateTime)#9 (1) {
      [&quot;milliseconds&quot;]=&gt;
      string(13) &quot;1635478989000&quot;
    }
  }
  [&quot;maxBsonObjectSize&quot;]=&gt;
  int(16777216)
  [&quot;maxMessageSizeBytes&quot;]=&gt;
  int(48000000)
  [&quot;maxWriteBatchSize&quot;]=&gt;
  int(100000)
  [&quot;localTime&quot;]=&gt;
  object(MongoDB\BSON\UTCDateTime)#10 (1) {
    [&quot;milliseconds&quot;]=&gt;
    string(13) &quot;1635478992136&quot;
  }
  [&quot;logicalSessionTimeoutMinutes&quot;]=&gt;
  int(30)
  [&quot;connectionId&quot;]=&gt;
  int(3)
  [&quot;minWireVersion&quot;]=&gt;
  int(0)
  [&quot;maxWireVersion&quot;]=&gt;
  int(13)
  [&quot;readOnly&quot;]=&gt;
  bool(false)
  [&quot;ok&quot;]=&gt;
  float(1)
  [&quot;$clusterTime&quot;]=&gt;
  array(2) {
    [&quot;clusterTime&quot;]=&gt;
    object(MongoDB\BSON\Timestamp)#11 (2) {
      [&quot;increment&quot;]=&gt;
      string(1) &quot;1&quot;
      [&quot;timestamp&quot;]=&gt;
      string(10) &quot;1635478989&quot;
    }
    [&quot;signature&quot;]=&gt;
    array(2) {
      [&quot;hash&quot;]=&gt;
      object(MongoDB\BSON\Binary)#12 (2) {
        [&quot;data&quot;]=&gt;
        string(20) &quot;&quot;
        [&quot;type&quot;]=&gt;
        int(0)
      }
      [&quot;keyId&quot;]=&gt;
      int(0)
    }
  }
  [&quot;operationTime&quot;]=&gt;
  object(MongoDB\BSON\Timestamp)#13 (2) {
    [&quot;increment&quot;]=&gt;
    string(1) &quot;1&quot;
    [&quot;timestamp&quot;]=&gt;
    string(10) &quot;1635478989&quot;
  }
}
</pre></div>
   </div>
  </div>
 </div>


 <div class="refsect1 changelog" id="refsect1-mongodb-driver-server.getinfo-changelog">
  <h3 class="title">更新日志</h3>
  <p class="para">
   <table class="doctable informaltable">
    
     <thead>
      <tr>
       <th>版本</th>
       <th>说明</th>
      </tr>

     </thead>

     <tbody class="tbody">
      <tr>
       <td>PECL mongodb 1.11.0</td>
       <td>
        When the driver is connected to a load balancer, this method returns
        the backing server&#039;s <code class="literal">hello</code> command response from the
        initial connection handshake.
       </td>
      </tr>

     </tbody>
    
   </table>

  </p>
 </div>


 <div class="refsect1 seealso" id="refsect1-mongodb-driver-server.getinfo-seealso">
  <h3 class="title">参见</h3>
  <ul class="simplelist">
   <li class="member"><span class="function"><strong>MongoDB\Driver\ServerDescription::getHelloResponse()</strong></span></li>
   <li class="member"><a href="https://www.mongodb.com/docs/manual/reference/command/hello/" class="link external">&raquo;&nbsp;hello</a> command in the MongoDB manual</li>
   <li class="member"><a href="https://github.com/mongodb/specifications/blob/master/source/server-discovery-and-monitoring/server-discovery-and-monitoring.rst" class="link external">&raquo;&nbsp;Server Discovery and Monitoring Specification</a></li>
  </ul>
 </div>


</div></div></div></body></html>